package com.x.erp.dao;

import com.x.erp.model.ShareCar;
import com.x.framework.dao.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * 车辆分享服务
 */
@Repository
public class ShareCarDao extends BaseDao {

	private String selectShareCarListSql = "SELECT " +
			"esc.*, " +
			"ec.CAR_TITLE, " +
			"ec.CAR_IMAGE_URL, " +
			"ec.CAR_MILEAGE, " +
			"ec.CAR_ORDER_STATE, " +
			"ec.CAR_BARGAIN_PRICE_STATE, " +
			"ec.CAR_LICENCE_STATE, " +
			"ec.CAR_AUTH_STATE, " +
			"ec.CAR_LICENCE_DATE, " +
			"ec.CAR_RETAIL_PRICE " +
			"FROM ERP_SHARE_CAR esc " +
			"LEFT JOIN ERP_CAR ec ON esc.CAR_ID = ec.CAR_ID " +
			"WHERE esc.SHARE_ID = ? ";
	/**
	 * 通过分享Id查询车辆分享列表
	 * @param shareCar
	 * @return
	 * @throws Exception
	 */
	public List<ShareCar> selectShareCarList(ShareCar shareCar) throws  Exception {
		StringBuilder sql = new StringBuilder(selectShareCarListSql);
		List<Object> params = new ArrayList<>();
		params.add(shareCar.getShareId());
		return this.queryForList(sql.toString(), ShareCar.class, params, shareCar);
	}
}
